<?php

namespace App\Jobs;

use App\Lib\QiNiuAdapter;
use App\Models\Star;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;

//implements ShouldQueue
class DeleteAttach
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public $timeout = 60;

    public $tries = 2;

    private $file;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($file)
    {
        $this->file = $file;
    }


    public function handle()
    {
        \Log::info("==============start delete attach job =========================");
        if (empty($this->file))
            return;
        foreach ($this->file as $item) {
            QiNiuAdapter::deleteResource($item['url']);
        }
        \Log::info("==============end delete attach job ============================");
    }
}
